package com.yangyouli.unity_demo_server.util;

import java.util.Random;

public class Generator {
	private static Random random = new Random(); 
	
	public static String generateNumberCode (int digit) {
		StringBuilder numStr = null;
		// 去除以 0 开始的验证码
		do {
			numStr = new StringBuilder(String.valueOf(Math.random()).substring(2));
		} while (numStr.charAt(0) == '0');
		if (numStr.length() < digit) {
			numStr.append(String.valueOf(Math.random()).substring(2));
		}
		return numStr.substring(0, digit);
	}
	
	public static int Range(int startNum, int endNum) {
		return Math.abs(random.nextInt()) % (endNum - startNum + 1) + startNum;
	}
}
